/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-10-26
 * Time: 0:51
 */

//面试题 17.16. 按摩师
public class Demo {
    /**
     1.创建dp表
     2.初始化
     3.填表
     4。返回值
     */
    public int massage(int[] nums) {
        int n = nums.length;
        if(n == 0) return 0; //特殊事例空数组
        int[] f = new int[n];
        int[] g = new int[n];

        f[0]=nums[0]; g[0]=0;
        for(int i = 1; i < n; i++){
            f[i] = g[i-1] + nums[i];
            g[i] = Math.max(f[i-1],g[i-1]);
        }
        return Math.max(f[n-1],g[n-1]);
    }

}
